home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / util / sys / 68040lib.lha / 68040Lib / Install / BuildMMUConfig.rexx < prev    next >
OS/2 REXX Batch file  |  2000-03-29  |  14KB  |  351 lines

  1. /*********************************************************
  2.  ** BuildMMUConfig                    **
  3.  **                            **
  4.  ** Builds the MMU-Configuration file automatically    **
  5.  ** from the boards information, including kludges for    **
  6.  ** bad or mis-designed hardware            **
  7.  ** Version 1.07 © 2000 THOR-Software, Thomas Richter   **
  8.  ** 28.03.2000                                          **
  9.  ** with special thanks to Tobias Abt and Niels Knoop    **
  10.  ** for the Board Ids                    **
  11.  *********************************************************/
  12.  
  13. PARSE ARG destination .
  14.  
  15.     if (destination = '') then
  16.         destination = '*'
  17.  
  18.     
  19.     rec = 25;
  20.  
  21.     if (OPEN(.out,destination,'W')) THEN; DO
  22.         rv=WRITELN(.out,";*************************************************************************");
  23.         rv=WRITELN(.out,";** MMU Configuration file                                              **");
  24.         rv=WRITELN(.out,";**                                                                     **");
  25.         rv=WRITELN(.out,";** this file is read on startup by the mmu.library and used to modify  **");
  26.         rv=WRITELN(.out,";** the pre-calculated or scanned MMU table                             **");
  27.         rv=WRITELN(.out,";**                                                                     **");
  28.         rv=WRITELN(.out,";** © 1999,2000 THOR Software, Thomas Richter                           **");
  29.         rv=WRITELN(.out,";*************************************************************************");
  30.         rv=WRITELN(.out,"");
  31.         rv=WRITELN(.out,"");
  32.         rv=WRITELN(.out,"");
  33.         rv=WRITELN(.out,"; the current version of the MMU library knows four commands that can");
  34.         rv=WRITELN(.out,"; be used in this file:");
  35.         rv=WRITELN(.out,"; CLEARTTX clears all or parts of the transparent translation registers");
  36.         rv=WRITELN(.out,"; ADDMEM   adds memory to the exec free list pool. BE WARNED, this command");
  37.         rv=WRITELN(.out,";          does NOT modify the MMU tables, this must be done manually with");
  38.         rv=WRITELN(.out,";          SETCACHEMODE");
  39.         rv=WRITELN(.out,"; SETCACHEMODE  defines the MMU tables.");
  40.         rv=WRITELN(.out,"; DESCRIPTORCACHEINHIBIT defines whether the data cache should be disabled");
  41.         rv=WRITELN(.out,"; for the MMU descriptors. It's usually OFF meaning the cache will remain");
  42.         rv=WRITELN(.out,"; enabled. This is fine for the mmu.library, but certain hacks might require");
  43.         rv=WRITELN(.out,"; an ON argument here. Note that this means more work for the library.");
  44.         rv=WRITELN(.out,"");
  45.         rv=WRITELN(.out,"");
  46.         rv=WRITELN(.out,"ClearTTx        ;ignore all TTX registers if any. We don't need them");
  47.         rv=WRITELN(.out,"");
  48.         rv=WRITELN(.out,";DescriptorCacheInhibit ON    ;make access to MMU descriptors cache inhibited");        
  49.         rv=WRITELN(.out,"");
  50.         rv=WRITELN(.out,"");
  51.         rv=WRITELN(.out,";Board specific setup follows here,");
  52.         rv=WRITELN(.out,";generated by BuildMMUConfig 1.07 © 28.03.2000 THOR-Software");
  53.         rv=WRITELN(.out,"");
  54.  
  55.         rv=WRITELN(.out,";General memory setup follows.");
  56.         rv=WRITELN(.out,";The following lines are a compatibility kludge for some P5 boards");
  57.         rv=WRITELN(.out,";which enable the MMU prior to the 68040/68060 library and leave");
  58.         rv=WRITELN(.out,";the memory in CACHEINHIBIT state. You may remove the following");
  59.         rv=WRITELN(.out,";lines on all other machines most likely.");
  60.         rv=WRITELN(.out,"");
  61.  
  62.         ADDRESS COMMAND "MemModes >T:MemInfo";
  63.         IF (OPEN(.meminfo,"T:MemInfo",'R')) THEN; DO 
  64.             DO UNTIL EOF(.meminfo)
  65.                 line = READLN(.meminfo);
  66.                 rv = WRITELN(.out,line);
  67.             END;
  68.             rv=CLOSE(.meminfo);
  69.         END;
  70.         
  71.         rv=WRITELN(.out,";Memory setup end.");
  72.         rv=WRITELN(.out,"");
  73.         rv=WRITELN(.out,"");
  74.  
  75.         ADDRESS COMMAND "ShowBoards to T:BoardInfo";
  76.         IF (OPEN(.boardinfo,"T:BoardInfo",'R')) THEN; DO
  77.             rec = 0;
  78.             DO UNTIL EOF(.boardinfo)
  79.                 line = READLN(.boardinfo)
  80.                 IF line ~= '' THEN; DO
  81.                     PARSE VAR line 'Type:' type 'Product:' product 'Manufacturer:' mf 'Serial#:' id 'BoardAddr:' from 'BoardSize:' size;
  82.                     type=X2D(type);
  83.                     product=X2D(product);
  84.                     mf=X2D(mf);
  85.                     id=X2D(id);
  86.                     dfrom=X2D(from);
  87.                     dsize=X2D(size);
  88.                     from=STRIP(from);
  89.                     size=STRIP(size);
  90.                     rv=WRITELN(.out,";Setup for board "mf"/"product);
  91.                     rv=IdentifyBoard(type,product,mf,id,from,size,dfrom,dsize);
  92.                     rv=WRITELN(.out,"");    
  93.                 END
  94.             END    
  95.             rv=CLOSE(.boardinfo);
  96.         END
  97.  
  98.         /* P5 setup kludges follow here..... Sigh */
  99.  
  100.         romlibs        = 0;            /* libs in ROM? */
  101.  
  102.         ADDRESS COMMAND 'P5Identify'
  103.         p5mode         = RC;            /* Possibly P5 board? */
  104.         ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"'
  105.         portmode     = RC;            /* MMU setup kludge? */
  106.         ADDRESS COMMAND 'FindResident "ppc.library"'
  107.         ppclibmode     = RC;            /* PPCLib in ROM? */
  108.         ADDRESS COMMAND 'FindResident "68060quick.library"'
  109.         quicklibmode     = RC;            /* quick lib in ROM? */
  110.         ADDRESS COMMAND 'FindResident "68060.library"'
  111.         libmode     = RC;            /* 060 lib in ROM? */
  112.         ADDRESS COMMAND 'FindResident "68040.library"'
  113.         lib4mode     = RC;            /* 040 lib in ROM? */
  114.  
  115.         IF p5mode ~= 0 THEN; DO
  116.             p5init         = 1
  117.             ppccheck    = 1
  118.         END;
  119.         
  120.         IF ppclibmode = 0 THEN; DO
  121.             ppccheck    = 1
  122.         END;
  123.  
  124.         IF portmode = 0 THEN; DO
  125.             ppccheck     = 1
  126.             p5init         = 1
  127.         END;
  128.  
  129.         IF (quicklibmode = 0) | (libmode = 0) | (lib4mode = 0) | (ppclibmode = 0) THEN; DO
  130.             p5init         = 1
  131.             romlibs        = 1
  132.             ppccheck    = 1
  133.         END;
  134.  
  135.         IF p5init = 1 THEN;DO
  136.             rv=WRITELN(.out,"");
  137.             rv=WRITELN(.out,";P5 fixes follow here:");
  138.             rv=WRITELN(.out,";If you do not own a P5 board, you may remove the following lines");
  139.             rv=WRITELN(.out,";");
  140.             rv=WRITELN(.out,";Several P5 boards build a private MMU setup on boot");
  141.             rv=WRITELN(.out,";using a kludge called the BOOT-MMU-Port. To run this");
  142.             rv=WRITELN(.out,";kludge, the following external command is run from");
  143.             rv=WRITELN(.out,";LIBS:mmu/ as all other external commands");
  144.             rv=WRITELN(.out,";");
  145.             rv=WRITELN(.out,";This command installs also other P5 relevant MMU settings");
  146.             rv=WRITELN(.out,";Hence, for P5 boards, please keep it in place even if");
  147.             rv=WRITELN(.out,";you *DO NOT* see the BOOT-MMU-Port.");
  148.             rv=WRITELN(.out,";");
  149.             IF ~EXISTS("LIBS:mmu") THEN; DO
  150.                 OPTIONS FAILAT 15
  151.                 ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU'
  152.                 OPTIONS FAILAT 10
  153.             END;
  154.             IF ~EXISTS("LIBS:mmu/P5Init") THEN; DO
  155.                 ADDRESS COMMAND 'Copy >NIL: P5Init to LIBS:MMU/P5Init'
  156.             END;
  157.             rv=WRITELN(.out,"P5Init");
  158.             rv=WRITELN(.out,"");
  159.             rv=WRITELN(.out,"");
  160.         END;            
  161.  
  162.         IF ppccheck = 1 THEN; DO
  163.             ADDRESS COMMAND 'PPCIdentify'
  164.             ppccheck = RC;
  165.         END;
  166.  
  167.         IF ppccheck = 1 THEN; DO
  168.             SAY "The setup script found a P5 board with PPC processor.";
  169.             SAY "While not a problem in general, please note that you";
  170.             SAY "absolutely *MUST NOT* use the ppc.library together";
  171.             SAY "with the mmu.library. This won't work.";
  172.         END;
  173.  
  174.         IF romlibs = 1 THEN; DO
  175.             rv=WRITELN(.out,"");
  176.             rv=WRITELN(.out,";This board has some processor libs resident");
  177.             rv=WRITELN(.out,";BPPCFix should be run to remove it.");
  178.             rv=WRITELN(.out,";This command has been installed into C:");
  179.             rv=WRITELN(.out,";by the setup script.");
  180.             SAY "The setup script found some processor libraries resident in ROM";
  181.             SAY "You will not be able to use the MuLib specific processor";
  182.             SAY "libraries unless you run BPPCFix in your startup-sequence.";
  183.             SAY "Please study the BPPCFix manual for details on how to run";
  184.             SAY "this program to replace the ROM-based libraries."
  185.             SAY "";
  186.             SAY "Note further that you *DO NOT* need the ENVARC:MMU-Configuration"
  187.             SAY "file if you continue to use the ROM resident libraries.";
  188.             SAY "";
  189.             IF ~EXISTS("C:BPPCFix") THEN; DO
  190.                 ADDRESS COMMAND 'Copy >NIL: BPPCFix to C:BPPCFix'
  191.                 SAY "Copied BPPCFix to C: for convenience...";
  192.             END;
  193.         END;
  194.  
  195.         rv=WRITELN(.out,"");
  196.         rv=CLOSE(.out);
  197.         ADDRESS COMMAND 'Delete T:BoardInfo QUIET'
  198.     END    
  199.  
  200. EXIT rec
  201.  
  202. IdentifyBoard:    PROCEDURE
  203. PARSE ARG type,product,mf,id,xfrom,xsize,from,size
  204.  
  205.     IF BitExtract(type,5) = '1' THEN; DO
  206.         rv=WRITELN(.out,";This board contains memory and requires no special threadment.");
  207.         rv=WRITELN(.out,";In case accessing this memory with COPYBACK enabled causes crashes,");
  208.         rv=WRITELN(.out,";please remove the semicolon in front of the next line:");
  209.         rv=WRITELN(.out,";SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  210.         sp = 1;
  211.     END; ELSE; DO
  212.         z2 = 0
  213.         z3 = 0
  214.         if (from >= X2D('00200000')) & (from+size <= X2D('00A00000')) THEN; DO
  215.             z2 = 1;
  216.         END;
  217.         if (from >= X2D('10000000')) & (from+size <= X2D('7FFFFFFF')) THEN; DO
  218.             z3 = 1;
  219.         END;
  220.         IF (mf = 18260) & (product = 19) THEN; DO
  221.             rv=WRITELN(.out,";Altais");
  222.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  223.             sp = 1;
  224.         END;
  225.         IF (mf = 18260) & (product = 16) & z3 THEN; DO
  226.             rv=WRITELN(.out,";Retina Z3");
  227.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'00c00000')" SIZE 0x00400000 CACHEINHIBIT NONSERIAL IMPRECISE");
  228.             sp = 1;
  229.         END;
  230.         IF (mf = 2117) & (product = 3) THEN; DO
  231.             rv=WRITELN(.out,";Merlin");
  232.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'00c00000')" SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  233.             sp = 1;
  234.         END;            
  235.         IF (mf = 2181) & (product = 0) & (size >= X2D('00100000')) & z2 THEN; DO
  236.             rv=WRITELN(.out,";oMniBus");
  237.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'00c00000')" SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  238.             sp = 1;
  239.         END;            
  240.         IF (mf = 2092) & (product = 33) & z3 THEN; DO
  241.             rv=WRITELN(.out,";Graffity Z3");
  242.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'00c00000')" SIZE 0x00200000 CACHEINHIBIT NONSERIAL IMPRECISE");
  243.             sp = 1;
  244.         END;
  245.         IF (mf = 2092) & (product = 33) & z2 THEN; DO
  246.             rv=WRITELN(.out,";Graffity Z2");
  247.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  248.             sp = 1;
  249.         END;        
  250.         IF (mf = 2167) & (product = 1) & z2 THEN; DO
  251.             rv=WRITELN(.out,";Domino");
  252.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  253.             sp = 1;
  254.         END;
  255.         IF (mf = 2167) & (product = 11) THEN; DO
  256.             rv=WRITELN(.out,";Picasso II");
  257.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  258.             sp = 1;
  259.         END;
  260.         IF (mf = 2167) & (product >= 21) & (product <= 24) THEN; DO
  261.             rv=WRITELN(.out,";Picasso IV");
  262.             sp = 1;
  263.         END;
  264.         IF (mf = 2193) & (product = 1) THEN; DO
  265.             rv=WRITELN(.out,";GVP Spectrum");
  266.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  267.             sp = 1;
  268.         END;
  269.         IF (mf = 2195) & (product = 5) THEN; DO
  270.             rv=WRITELN(.out,";Piccolo");
  271.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  272.             sp = 1;
  273.         END;
  274.         IF (mf = 2195) & (product = 10) & z2 THEN; DO
  275.             rv=WRITELN(.out,";Piccolo-SD64 Z2");
  276.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" CACHEINHIBIT NONSERIAL IMPRECISE");
  277.             sp = 1;
  278.         END;
  279.         IF (mf = 2195) & (product = 10) & z3 THEN; DO
  280.             rv=WRITELN(.out,";Piccolo-SD64 Z3");
  281.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x00400000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  282.             sp = 1;
  283.         END;
  284.         IF (mf = 8512) & (product = 34) & z3 THEN; DO
  285.             sp = 1;
  286.             rv=WRITELN(.out,";CyberVision Z3");
  287.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" BLANK IOSPACE");
  288.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x01400000 VALID IOSPACE CACHEINHIBIT");
  289.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'01400000')" SIZE 0x00c00000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  290.             rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'02000000')" SIZE 0x02000000 VALID IOSPACE CACHEINHIBIT");
  291.         END;
  292.         IF (mf = 8512) & (product = 67) THEN; DO
  293.             sp = 1;
  294.             rv=WRITELN(.out,";CyberVision3D");
  295.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" BLANK IOSPACE");
  296.             IF Z2 THEN; DO
  297.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x00380000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  298.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'00380000')" SIZE 0x00080000 VALID IOSPACE CACHEINHIBIT");
  299.             END; ELSE; DO
  300.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'04000000')" SIZE 0x01000000 VALID IOSPACE CACHEINHIBIT NONSERIAL IMPRECISE");
  301.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'05000000')" SIZE 0x00010000 VALID IOSPACE CACHEINHIBIT");
  302.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'05800000')" SIZE 0x00008000 VALID IOSPACE CACHEINHIBIT");
  303.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'07000000')" SIZE 0x00008000 VALID IOSPACE CACHEINHIBIT");
  304.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'08000000')" SIZE 0x00001000 VALID IOSPACE CACHEINHIBIT");
  305.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'0C000000')" SIZE 0x00010000 VALID IOSPACE CACHEINHIBIT");
  306.                 rv=WRITELN(.out,"SetCacheMode FROM 0x"Add(xfrom,'0C0E0000')" SIZE 0x00001000 VALID IOSPACE CACHEINHIBIT");
  307.             END
  308.         END;    
  309.         IF (mf = 2145) & (product = 33) THEN; DO
  310.             sp = 1;
  311.             rv=WRITELN(.out,";Rainbow 3");
  312.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" BLANK IOSPACE");
  313.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x00400000 VALID IOSPACE CACHEINHIBIT");
  314.         END;
  315.         IF (mf = 8512) & (product = 100) THEN; DO
  316.             sp = 1;
  317.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" BLANK IOSPACE");
  318.         END;
  319.         IF (mf = 8512) & (product = 110) THEN; DO
  320.             sp = 1;
  321.             rv=WRITELN(.out,"SetCacheMode FROM 0x"xfrom" SIZE 0x"xsize" BLANK IOSPACE");
  322.         END;
  323.         IF (sp = 0) THEN; DO
  324.             rv=WRITELN(.out,";no special care has been taken for this board.");
  325.         END;
  326.         
  327.     END    
  328.  
  329. RETURN 0
  330.  
  331. ;
  332. ; The AREXX BITTST function seems to be broken. We implement our own
  333. ;
  334. BitExtract:    PROCEDURE
  335. PARSE ARG num,bit
  336.     bit=SUBSTR(C2B(D2C(num)),8-bit,1);
  337. RETURN bit
  338.  
  339. ;
  340. ; ARexx uses floating point addition and causes a mess about it when
  341. ; converting this back to integer. Therefore, we use another approach for
  342. ; adding numbers.
  343. ; Luckely, boards are aligned...
  344. Add:        PROCEDURE
  345. PARSE ARG base,offset
  346.     offset = LEFT(offset,LENGTH(offset)-2)
  347.     base   = LEFT(base,LENGTH(base)-2)
  348.     base   = D2X(X2D(offset)+X2D(base))'00'
  349. RETURN base
  350.  
  351.